<?php
App::loadLib ( "JieKu.FrameWork.Controller" );
class schools extends Controller {
	function __construct() {
	
	}
	function edit() {
		$view = $this->jieku->getView ();
		$db = $this->jieku->getDB ();
		
	}
	function item() {
		$view = $this->jieku->getView ();
		$db = $this->jieku->getDB ();
		$db->query(JDBTool::selectByList(
			array(
			"member.id as member_id",
			"member.username as member_username",
			"schooltype.title as schooltype_title",
			"schooltype.id as schooltype_id",
			"school.title as school_title",
			"school.citys as school_cityes",
			"school.id as school_id"
			),
			array(
				"px_school as school",
				"px_member as member",
				"px_schooltype as schooltype"
			),
			"
				school.member_id=member.id and
				school.schooltype_id=schooltype.id
			"
		));
		list($result, $count) = $db->getCountByList();
	}
	function addform(){
		$view = $this->jieku->getView ();
		$db = $this->jieku->getDB ();
		$db->query(JDBTool::select( array(
									'id',
									'title'
									),
									array(
									'px_schooltype'
									),
									"pid = 0"));
		$view->add("pList",$db->getAll());
		App::loadData("JieKu.Data.City");
		$city=new City();
		$view->add("citys",$city->getAll());					
	}
	function addtype(){
		
	}
	function add(){
		$localDir=APP_UPLOAD_ROOT."schoollogo/".date("Y/m/d/");
		mkdir($localDir,0777,true);
		$localFileName=$localDir.$_FILES['school']['name']['logoimg'];
		rename($_FILES['school']['tmp_name']['logoimg'], $localFileName);
		$db = $this->jieku->getDB();
		$school=$this->jieku->var['school'];
		$school['logoimg']=$localFileName;
		$db->exec(JDBTool::insert('px_school',$school));
		$this->actionForward("addform");
		//print_r($this->jieku->var);
	}
}
?>